<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表页面</title>
    <link href="/static/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="/static/js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="/static/js/echarts.js"></script>
</head>
<body>

<h4>当前用户：${username}</h4>
<div class="text-center">

<form style="text-align: center" method="post" action="list">
    场馆：<select name="xid">
        <option value="">请选择</option>
    </select>
    项目类型：<select name="yid">
        <option value="">请选择</option>
    </select>
    场地：<select name="zid">
        <option value="">请选择</option>
    </select>
    <input type="submit" value="搜索">&nbsp;&nbsp;&nbsp;
    <a href="/toAdd"><input type="button" value="场馆设置"></a>&nbsp;&nbsp;&nbsp;
    <a href="toBarEchars"><input type="button" value="统计报表"></a>
</form>


<table class="table">
    <tr>
        <td>场馆</td>
        <td>项目类型</td>
        <td>场地</td>
        <td>开始时间</td>
        <td>结束时间</td>
        <td>价格</td>
        <td>最近更新时间</td>
        <td>最近更新人</td>
    </tr>
    <c:forEach items="${pg.list}" var="main">
        <tr>
            <td>${main.xname}</td>
            <td>${main.yname}</td>
            <td>${main.zname}</td>
            <td>${main.startTime}</td>
            <td>${main.endTime}</td>
            <td>${main.price}</td>
            <td>
                <fmt:formatDate value="${main.created}" pattern="yyyy-MM-dd HH:mm:ss"/>
            </td>
            <td>${main.username}</td>
        </tr>
    </c:forEach>
</table>
<jsp:include page="/static/common/pages.jsp"></jsp:include>

</div>

<script type="text/javascript">

    //下拉框
    $.post(
        "listStadium",
        function (list){
            for (var i in list) {
                $("[name='xid']").append('<option value="'+list[i].xid+'">'+list[i].xname+'</option>');
            }
            $("[name='xid']").val(${main.xid});
        }
    );
    $.post(
        "listType",
        function (list){
            for (var i in list) {
                $("[name='yid']").append('<option value="'+list[i].yid+'">'+list[i].yname+'</option>');
            }
            $("[name='yid']").val(${main.yid});
        }
    );
    $.post(
        "listPlace",
        function (list){
            for (var i in list) {
                $("[name='zid']").append('<option value="'+list[i].zid+'">'+list[i].zname+'</option>');
            }
            $("[name='zid']").val(${main.zid});
        }
    );



</script>

</body>
</html>
